from mxit.connection import MxitConnection

class Listener:
    def registration_received(self, data):
        print data
    
    def message_received(self, message):
        print message
        
def read_input(message, default=None):
    print "Enter %s (default: %s)" % (message, default)
    line = raw_input().strip()
    if len(line):
        return line
    else:
        return default
    

username = read_input("username")
password = read_input("password")
name = read_input("name")
birthdate = read_input("birth date")
clientid = read_input("client id")

print username, password, name, birthdate, clientid


con = MxitConnection(listener=Listener(), id=username, password=password, client_id=clientid)

    
print "connecting..."
con.connect()
print "sending registration"
con.register(name, birthdate)
print "listening"
con.listen()
